﻿@model PrjctMngmt.Models.Issue

<script type="text/javascript">
    $(function () {
        $("#category").dialog({
            autoOpen: false, width: 400, modal: true,
            buttons: {
                "Save": function () {
                    $.post("/IssueCategory/Create",
                        $("#IssueCategoryForm").serialize(),
                        function () {
                            $("#category").dialog("close");
                            window.location.reload();
                        });
                },
                Cancel: function () { $(this).dialog("close"); }
            }
        });
        $(".addCategory").click(function () {
            $("#category").html("")
                .dialog("option", "title", "Create category")
                .load("/IssueCategory/Create", function () { $("#category").dialog("open"); });
        });
    });
</script>

<script type="text/javascript">
    $(function () {
        $("#milestone").dialog({
            autoOpen: false, width: 400, modal: true,
            buttons: {
                "Save": function () {
                    $.post("/Milestone/CreateDialog",
                        $("#MilestoneForm").serialize(),
                        function () {
                            $("#milestone").dialog("close");
                            window.location.reload();
                        });
                },
                Cancel: function () { $(this).dialog("close"); }
            }
        });
        $(".addMilestone").click(function () {
            $("#milestone").html("")
                .dialog("option", "title", "Create milestone")
                .load("/Milestone/CreateDialog", function () { $("#milestone").dialog("open"); });
        });
    });
</script>

<script type="text/javascript" >
    $(document).ready(function () {
        $("#editor").markItUp(mySettings);
    });
</script>

@using (Html.BeginForm(@*null, null, FormMethod.Post, new { enctype = "multipart/form-data" }*@)) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Issue</legend>

        <p>* indicates a required field.</p>

        <div class="editor-label">
            @Html.LabelFor(model => model.Subject)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Subject) *
            @Html.ValidationMessageFor(model => model.Subject)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Priority)
        </div>
        <div class="editor-field">
            @Html.DropDownList("Priority", (IEnumerable<SelectListItem>)ViewData["Priority"], "")
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Severity)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Severity)
            @Html.ValidationMessageFor(model => model.Severity)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Status)
        </div>
        <div class="editor-field">
            @Html.DropDownList("Status", (IEnumerable<SelectListItem>)ViewData["Status"], "")
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Description)
        </div>
        <div class="editor-field">
            @Html.TextAreaFor(model => model.Description, new { @cols = 50, @rows = 10, @id = "editor" }) *
            @Html.ValidationMessageFor(model => model.Description)
        </div>

        <div class="editor-label">
            Category
        </div>
        <div class="editor-field Top">
            @Html.DropDownList("IssueCategoryName", (IEnumerable<SelectListItem>)ViewData["IssueCategories"], "")
            <img alt="Create category" class="addCategory ButtonLink Top" src="../../Content/themes/base/images/plus-sign_small.png" />
        </div>

        <div class="editor-label">
            Project
        </div>
        <div class="editor-field">
            @Html.DropDownList("ProjectID", (IEnumerable<SelectListItem>)ViewData["Projects"], "") *
        </div>

        <div class="editor-label">
            Milestone
        </div>
        <div class="editor-field Top">
            @Html.DropDownList("MilestoneID", (IEnumerable<SelectListItem>)ViewData["Milestones"], "")
            <img alt="Create milestone" class="addMilestone ButtonLink Top" src="../../Content/themes/base/images/plus-sign_small.png" />
        </div>

        <!--
        <div class="editor-label">
            File
        </div>
        <div class="editor-field">
            <input type="file" name="File" />
        </div>
        -->
        <p>
            <input type="submit" value="Submit" />
        </p>

        <div id="category"></div>
        <div id="milestone"></div>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>
